import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import { eslint } from 'rollup-plugin-eslint';
import babel from 'rollup-plugin-babel';
import replace from 'rollup-plugin-replace';
import { uglify } from 'rollup-plugin-uglify';

const isProd = process.env.NODE_ENV === 'production';

const version = "1.0.0";
const fileName = `api-${version}${(isProd ? '.min' : '')}.js`

export default {
    input: `src/index.js`,
    output: {
        file: `dist/${fileName}`,
        format: 'iife'
    },
    plugins: [
        resolve(),
        commonjs(),
        eslint({
            throwOnError: true,
            throwOnWarning: true,
            include: ['src/**'],
            exclude: ['node_modules/**']
        }),
        babel({
            exclude: 'node_modules/**',
            runtimeHelpers: true,
        }),
        replace({
            exclude: 'node_modules/**',
            ENV: process.env.NODE_ENV,
        }),
        (isProd && uglify()),
    ],
};
